package com.example.xxtautosignjava.utils;

import org.apache.http.impl.client.BasicCookieStore;

import java.util.HashMap;
public class CookieUtils {

    public HashMap<String, String> convertCookie(String cookie) {
        HashMap<String, String> cookiesMap = new HashMap<String, String>();
        String[] items = cookie.trim().split(";");
        for (String item : items) cookiesMap.put(item.split("=")[0], item.split("=")[1]);
        return cookiesMap;
    }

    public HashMap<String, String> convertCookieStore(BasicCookieStore store) {
        HashMap<String, String> map = new HashMap<>();
        for (int i = 0; i < store.getCookies().size(); i++) {
            map.put(store.getCookies().get(i).getName(), store.getCookies().get(i).getValue());
        }
        System.out.println(map);
        return map;
    }

}
